package light.mvc.model.workflow;

import java.util.Date;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import light.mvc.model.base.IdEntity;
import light.mvc.model.sys.Tuser;

/**
 * 流转的表单文档
 * 
 * @author tyg
 * 
 */
@Entity
@Table(name = "workflow_form")
public class Tform extends IdEntity implements java.io.Serializable{

	/** 表单状态常量：审批中 */
	public static final String STATUS_RUNNING = "审批中";

	/** 表单状态常量：已通过 */
	public static final String STATUS_APPROVED = "已通过";

	/** 表单状态常量：未通过 */
	public static final String STATUS_REJECTED = "未通过";

	private TformTemplate formTemplate;// 所使用的文档模板
	private Set<TapproveInfo> approveInfos = new HashSet<TapproveInfo>();
	private Tuser applicant;// 申请人
	private String processInstanceId;//该表单所属的流程实例

	private String title;// 标题
	private Date applyTime;// 申请时间
	private String path;// 文档的存储路径
	private String status; // 当前的状态
	
	private String startTime; // 休假起始时间
	private String endTime; // 休假结束时间
	private String register; // 注册登记人

	public String getRegister() {
		return register;
	}

	public void setRegister(String register) {
		this.register = register;
	}

	public String getStartTime() {
		return startTime;
	}

	public void setStartTime(String startTime) {
		this.startTime = startTime;
	}

	public String getEndTime() {
		return endTime;
	}

	public void setEndTime(String endTime) {
		this.endTime = endTime;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "userid")
	public Tuser getApplicant() {
		return applicant;
	}

	public String getProcessInstanceId() {
		return processInstanceId;
	}

	public void setProcessInstanceId(String processInstanceId) {
		this.processInstanceId = processInstanceId;
	}

	public void setApplicant(Tuser applicant) {
		this.applicant = applicant;
	}

	public Date getApplyTime() {
		return applyTime;
	}

	public void setApplyTime(Date applyTime) {
		this.applyTime = applyTime;
	}

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "formTemplateid")
	public TformTemplate getFormTemplate() {
		return formTemplate;
	}

	public void setFormTemplate(TformTemplate formTemplate) {
		this.formTemplate = formTemplate;
	}
	
	
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "form")
	@OrderBy("id ASC") 
	public Set<TapproveInfo> getApproveInfos() {
		return approveInfos;
	}

	public void setApproveInfos(Set<TapproveInfo> approveInfos) {
		this.approveInfos = approveInfos;
	}


}
